<template>
  <div>
    <ul>
      <li v-for="(item,idx) in arr" :key="idx">
        {{item}}
        <button @click="arr.splice(idx,1)">删除</button>
      </li>
      
    </ul>
    <button @click="fn">生成</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr:[1,5,3],
      index:0
    }
  },
  methods: {
    fn(){
     this.index = parseInt(Math.random()*20)
     this.arr.push(this.index)
    }
  },
}
</script>